﻿<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EDGE;IE=11;IE=8,chrome=1" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>生产作业平衡</title>
    <link href="/InSiteWebApplication/Content/Easyui/themes/metro/easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/custom-easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/themes/icon.css" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href="/InSiteWebApplication/Content/AnyGantt/css/anychart-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="/InSiteWebApplication/Content/AnyGantt/fonts/css/anychart-font.min.css" />
    <style>
        .datagrid-cell{padding:0}
        #ApsTestlayout .panel-header{padding:0}
        #ApsTestlayout .panel-title{height: 24px;line-height: 24px;}
       
        .datagrid-body::-webkit-scrollbar{width:0px;height:8px;}
        .datagrid-body::-webkit-scrollbar-thumb {background:rgba(0,0,0,0.2);border-radius:4px;}
          .l-btn2
{
border: #d2d2d2 1px solid;
FONT-FAMILY: Tahoma, Helvetica; 
FONT-SIZE: 10px; 
CURSOR: hand; FONT-WEIGHT: 500;TEXT-DECORATION: none; 
cursor:pointer;
height:26px;
color:#fff;
background:#02bfbf;
}
.l-btn2:hover
{ color:#fff;
   background:#05d2d2;
    }
    .ganttDiv{background: red;
    display: inline-block;
    position: absolute;
    left: 180px;
    width: 200px;
    margin-top: 5px;height: 15px}
    </style>
</head>
<body>
    <div class="panelSection">    
        <div class="easyui-panel " title="查询区域" style="padding:3px;width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
           <form id="searchForm" method="post">
	    	<table>
	    		<tr class="divLabel">
                    <td>批次计划开始:</td>
                    <td>批次计划结束:</td>
	    		</tr>
	    		<tr>
	    			<td><input id="plans" name="Factory" class="easyui-datebox" style="width: 120px; height: 22px" data-options='editable:false'/></td>
                    <td><input id="plane" name="shift" class="easyui-datebox" style="width: 120px; height: 22px" data-options='editable:false'/></td>
                    <td><a href="javascript:void(0)" class="easyui-linkbutton not-custom l-btn2" style="width:60px" onclick="page.searchData()">查询</a></td>
	    			<td><a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.searchReset()">重置</a></td>
	    		</tr>
	    	</table>
	    </form>
        </div> 
    </div>

    <div class="panelSection">    
        <div class="easyui-panel " title="查询结果" style="padding:3px;width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
            <div id="ApsTestlayout" class="easyui-layout" style="height:390px" >
                 <div data-options="region:'center'" id="center" style="width:46%;" > 
                    <table id="ApsTest" style="height:380px;width:100%;" scrollbarSize:'0' data-options="rownumbers:true,fit:true,border:false,toolbar: '#tb'"></table>
                  </div>
                  <div data-options="region:'east',title:' '" style="width:54%;" id="east">
                    <table id="ApsTest1" style="height:363px;" data-options="border:false"></table>
                </div>
            </div>
            <table id="ApsSpec" style="height:340px;" data-options="rownumbers:true,toolbar:'#tb1'"></table>
        </div>
    </div>
       <div id="tb" style="height:auto">
		    <!--<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="getChanges()">列筛选</a>-->
            <span style="display:"><input class="easyui-combogrid not-custom"  id="Apscolumns" style="width: 25px; height: 22px;" data-options="multiple:true"/></span>
	    </div>
        <div id="tb1" style="height:auto">
		    <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-reload'" onclick="page.returnContainer()">返回</a>
	    </div>
        <!--<table id="Table1" style="height:363px;" data-options="border:false"></table>-->
        <table id="tt" style="height:400px"></table>
     <!--信息提示区域-->
     <div id="statusMessage" style="font-size: 14px; height: 40px"></div>
</body>
</html>
<script src="/InSiteWebApplication/Scripts/json2.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/array.pollyfill.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/CustomCommon.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/dayjs.min.js" type="text/javascript"></script>

<script>
    //创建人：longb
    //日期：2023-08-07
    //描述：生产作业平衡
    var page = {
        rootPath: getRootPath(), //网站根路径
        ajaxUrl: getRootPath() + "/Ashx/ApsHandler/ApsWorkStationHandler.ashx",
        init: function () {
            $('#plans').datebox('setValue', dayjs().startOf('month').format('YYYY-MM-DD'));
            $('#plane').datebox('setValue', dayjs().endOf('month').format('YYYY-MM-DD'));
            page.bind();
            page.initData();
        },
        //页面事件绑定
        bind: function () {
            var columns = [];
            var Spancolumns = [];
            var specColumns = [{ field: 'SPECNO', title: '工序号', width: 60, align: 'center' },
                 { field: 'SPECNAME', title: '工序名称', width: 90, align: 'center' },
                 { field: 'SPECTYPE', title: '工序类型', width: 80, align: 'center' },
                 { field: 'EQU', title: '设备', width: 80, align: 'center' },
                 { field: 'PLANSTART', title: '计划开始', width: 100, align: 'center' },
                 { field: 'PLANEND', title: '计划完成', width: 100, align: 'center' },
                 { field: 'PLANTIME', title: '持续时间（H）', width: 90, align: 'center' },
                 { field: 'PREPARECYCLE', title: '准备时间（min）', width: 100, align: 'center' },
                 { field: 'MAKECYCLE', title: '加工时间（min）', width: 100, align: 'center' },
                 { field: 'TRANSFERCYCLE', title: '转运时间（H）', width: 90, align: 'center' },
                 { field: 'COMMICYCLE', title: '外委周期', width: 70, align: 'center' }
                 ];
            for (var i = 1; i <= 29; i++) {
                //columns.push({ field: 'day' + i, title: i, width: 30, align: 'center', formatter: function (value, row, index) { var day = Number(this.field.replace('day', '')); if (row.DAYS <= day && row.DAYE >= day) { return '<div class="backg" style="background-color: #409EFF;height: 15px;width:30px;"></div>'; } } });
                specColumns.push({ field: 'day' + i, title: i, width: 30, align: 'center', formatter: function (value, row, index) { var day = Number(this.field.replace('day', '')); if (row.DAYS <= day && row.DAYE >= day) { return '<div style="background-color: #ffee00;height: 15px;width:30px;"></div>'; } } });
            }

            var plans = $("#plans").datebox('getValue');
            var plane = $("#plane").datebox('getValue');
            var startDated = Date.parse(plans);
            var endDated = Date.parse(plane);
            var date = Math.abs(endDated - startDated);
            var allDay = Math.floor(date / (1000 * 3600 * 24));
            for (var i = 0; i <= allDay; i++) {
                var date = dayjs(plans).add(i, 'day'); //批次计划开始
                if (allDay <= 7) {//一周内
                    var isExist = Spancolumns.some(function (i) {
                        return i.field === date.format('MM-DD')
                    });
                    if (!isExist) {
                        Spancolumns.push({ field: date.format('MM-DD'), title: date.format('MM-DD'), colspan: 24, align: 'center' });
                    }
                    for (j = 0; j < 24; j++) {
                        var dateh = date.add(j, 'hour');
                        columns.push({ field: dateh.format('YYYY-MM-DD HH'), title: dateh.format('HH') + ":00", width: 30, align: 'center', formatter: function (value, row, index) {
                            var day = dayjs(this.field);
                            console.info((dayjs(row.PLANSTART) <= day && dayjs(row.PLANEND) >= day) + '--' + row.PLANEND + "--" + this.field + '--' + row.PLANSTART);
                            if (dayjs(dayjs(row.PLANSTART).format('YYYY-MM-DD HH:mm')) <= day && dayjs(dayjs(row.PLANEND).format('YYYY-MM-DD HH:mm')) > day) {
                                return '<div class="backg"  style="background-color: #409EFF;height: 15px;width:30px;"></div>';
                            }
                        }
                        });
                    }

                }


                if (allDay > 7 && allDay <= 31) {//一个月内
                    var isExist = Spancolumns.some(function (i) {
                        return i.field === date.format('YYYY-MM')
                    });
                    if (!isExist) {
                        var colspan = allDay + 1;
                        if (dayjs(plans).endOf('month').format('YYYY-MM') != dayjs(plane).endOf('month').format('YYYY-MM')) {//判断开始和结束 ---是否同一月份
                            if (Spancolumns.length == 0) {//第一个月
                                colspan = dayjs(date).endOf('month').get('date') - date.get('date') + 1;
                            } else {
                                colspan = dayjs(plane).get('date') - dayjs(date).startOf('month').get('date') + 1;
                            }
                        }
                        //console.info(colspan);
                        Spancolumns.push({ field: date.format('YYYY-MM'), title: date.format('YYYY-MM'), colspan: colspan, align: 'center' });
                    }
                    columns.push({ field: date.format('YYYY-MM-DD'), title: date.get('date'), width: 30, align: 'center', formatter: function (value, row, index) {
                        var day = dayjs(this.field); //console.info((dayjs(row.PLANEND) >= day) + '--' + row.PLANEND + "--" + this.field);
                        if (dayjs(dayjs(row.PLANSTART).format('YYYY-MM-DD')) <= day && dayjs(dayjs(row.PLANEND).format('YYYY-MM-DD')) >= day) {
                            return '<div class="backg"  style="background-color: #409EFF;height: 15px;width:30px;"></div>';
                        }
                    }
                    });
                }

                if (allDay > 31 && allDay <= 365) {//一年内
                    var smonth = dayjs(plans).get('month');
                    var emonth = dayjs(plane).get('month');
                    var isExist = Spancolumns.some(function (i) {
                        return i.field === date.format('YYYY')
                    });
                    if (!isExist) {
                        Spancolumns.push({ field: date.format('YYYY'), title: date.format('YYYY'), colspan: emonth - smonth + 1, align: 'center' });
                    }
                    var isExistM = columns.some(function (i) {
                        return i.field === date.format('YYYY-MM')
                    });
                    if (!isExistM) {
                        columns.push({ field: date.format('YYYY-MM'), title: date.format('YYYY-MM'), width: 90, align: 'center', formatter: function (value, row, index) { var date = dayjs(this.field + "-01"); console.info((dayjs(row.PLANSTART).startOf('month') <= date) + '--' + (dayjs(row.PLANEND).endOf('month') >= date) + '--' + (this.field) + "--" + (row.PLANSTART) + '--' + (row.PLANEND)); if (dayjs(row.PLANSTART).startOf('month') <= date && dayjs(row.PLANEND).endOf('month') >= date) { return '<div class="backg" style="background-color: #409EFF;height: 15px;width:90px;"></div>'; } } });
                    }
                }
            }


            var Apscolumns = [{ field: 'CONTAINER', title: '批次号', width: 120, formatter: function (value, row, index) { return '<a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.SelectContainer(\'' + value + '\')">' + value + '</a>'; } },
                 { field: 'WORKFLOWNERSION', title: '工艺版本', width: 120, align: 'center' },
                 { field: 'WORKFLOWSTEP', title: '当前工序', width: 120, align: 'center' },
                 { field: 'ISCOMP', title: '生产准备齐套', width: 90, align: 'center' },
                 { field: 'WORKCENTER', title: '当前工区', width: 100, align: 'center' },
                 { field: 'PLANSTART', title: '计划开始', width: 150, align: 'center' },
                 { field: 'PLANEND', title: '计划完成', width: 150, align: 'center'}];

            $('#ApsTest').datagrid({
                singleSelect: true,
                frozenColumns: [[{ field: 'X', title: '预警', width: 80, rowspan: 2}], []],
                columns: [Apscolumns],
                onSelect: function (index, row) {
                },
                onLoadSuccess: function (data) {
                    //$('#ApsTest').datagrid('freezeColumn', 'PLANEND');
                }
            });

            $('#ApsTest1').datagrid({
                columns: [Spancolumns, columns],
                onLoadSuccess: function (data) {
                    //$('.backg').parent().parent().css('border-right','none');
                    //$('#east .datagrid-body:eq(1)').find('td').css('border-style', 'dotted none');
                    var width = 0;
                    for (var j = 0; j < data.total; j++) {
                        //var rowid = $('tr[datagrid-row-index="' + j + '"]');
                        var rowid = $('#ApsTest1').parent().find('.datagrid-view2').find('tr[datagrid-row-index="' + j + '"]');
                        var colspan = rowid.children().find('.backg').length;
                        width = rowid.children().find('.backg').width();
                        rowid.children().find('.backg').parent().eq(0).parent().attr('colspan', colspan);
                        rowid.children().find('.backg').css('width', width * colspan + 'px');
                        rowid.children().find('.backg').parent().eq(0).css('width', width * colspan + 'px');
                        for (var i = 1; i <= colspan; i++) {
                            rowid.children().find('.backg').parent().eq(i).parent().css('display', 'none');
                        }
                    }
                    $('.datagrid-view2').find('td').css('width', width + 'px')
                    var l = $('#east .datagrid-body:eq(1)');
                    l.scroll(function () {
                        $('#center .datagrid-body').scrollTop(this.scrollTop)
                    })

                },
                onAfterRender: function (target) {
                    $('#ApsTest1').datagrid('getPanel').removeClass('lines-both lines-no lines-right lines-bottom');
                }
            });

            $('#Table1').datagrid({
                columns: [Spancolumns, columns],
                onLoadSuccess: function (data) {
                    var width = 0;
                    for (var j = 0; j < data.total; j++) {
                        var rowid = $(this).parent().find('.datagrid-view2').find('tr[datagrid-row-index="' + j + '"]');
                        var width = rowid.find('td').eq(0).width() + 1;
                        var colspan = 0; //rowid.children().find('.backg').length;
                        //width = rowid.children().find('.backg').width();
                        //var startDate = rowid.children().find('.backg').parent().eq(0).parent().attr('field');
                        var startDate = data.rows[j].PLANSTART;
                        var endDate = data.rows[j].PLANEND;
                        var plans = $("#plans").datebox('getValue') + " 00:00:00";
                        var plane = $("#plane").datebox('getValue') + " 23:59:00";
                        if (dayjs(startDate) <= dayjs(plans)) { startDate = plans; } //批次开始<=选择开始
                        if (dayjs(endDate) >= dayjs(plane)) { endDate = plane; } //批次结束》选择结束

                        var difftype = 'hour'
                        var diffday = page.getDays(plans, plane);
                        if (diffday > 7) {//日期天模式
                            difftype = 'day'
                            startDate = dayjs(startDate).format('YYYY-MM-DD');
                            endDate = dayjs(endDate).format('YYYY-MM-DD');
                        }
                        if (dayjs(endDate) >= dayjs(plane)) { //批次结束日期》=选择的结束日期
                            if (diffday > 7) {
                                colspan = dayjs(plane).diff(startDate, difftype) + 1
                                //colspan = page.getDays(startDate, plane) + 1
                            } else {//小时模式
                                colspan = dayjs(plane).diff(startDate, difftype) + 1
                            }
                        } else {//批次结束日期》=选择的结束日期
                            if (diffday > 7) {
                                colspan = dayjs(endDate).diff(startDate, difftype) + 1
                                //colspan = page.getDays(startDate, endDate) + 1
                            } else {
                                colspan = Math.ceil(dayjs(endDate).diff(startDate, difftype, true)); console.info(colspan);
                                console.info(dayjs(endDate).format('YYYY-MM-DD HH') + "-------" + dayjs(startDate).format('YYYY-MM-DD HH'));
                            }
                        }


                        var diff_day = dayjs(startDate).diff(plans, difftype)
                        if (dayjs(endDate) > dayjs(startDate)) {
                            rowid.css('position', 'relative');
                            rowid.append("<div class='ganttDiv' style='width:" + width * colspan + "px;left:" + diff_day * width + "px'></div>");
                        }

                    }
                }
            });

            $('#tt').treegrid({
                collapsible: true,
                animate:true,
                idField: 'id',
                treeField: 'CONTAINER',
                frozenColumns: [Apscolumns],
                columns: [Spancolumns, columns],
                onLoadSuccess: function (row, data) {
                    var width = 0;
                    for (var j = 0; j < data.total; j++) {
                        var rowid = $(this).parent().find('.datagrid-view2').find('tr[node-id="' + data.rows[j].id + '"]');
                        var width = rowid.find('td').eq(0).width() + 1;
                        var colspan = 0; //rowid.children().find('.backg').length;
                        //width = rowid.children().find('.backg').width();
                        //var startDate = rowid.children().find('.backg').parent().eq(0).parent().attr('field');
                        var startDate = data.rows[j].PLANSTART;
                        var endDate = data.rows[j].PLANEND;
                        var plans = $("#plans").datebox('getValue') + " 00:00:00";
                        var plane = $("#plane").datebox('getValue') + " 23:59:00";
                        if (dayjs(startDate) <= dayjs(plans)) { startDate = plans; } //批次开始<=选择开始
                        if (dayjs(endDate) >= dayjs(plane)) { endDate = plane; } //批次结束》选择结束

                        var difftype = 'hour'
                        var diffday = page.getDays(plans, plane);
                        if (diffday > 7) {//日期天模式
                            difftype = 'day'
                            startDate = dayjs(startDate).format('YYYY-MM-DD');
                            endDate = dayjs(endDate).format('YYYY-MM-DD');
                        }
                        if (dayjs(endDate) >= dayjs(plane)) { //批次结束日期》=选择的结束日期
                            if (diffday > 7) {
                                colspan = dayjs(plane).diff(startDate, difftype) + 1
                                //colspan = page.getDays(startDate, plane) + 1
                            } else {//小时模式
                                colspan = dayjs(plane).diff(startDate, difftype) + 1
                            }
                        } else {//批次结束日期》=选择的结束日期
                            if (diffday > 7) {
                                colspan = dayjs(endDate).diff(startDate, difftype) + 1
                                //colspan = page.getDays(startDate, endDate) + 1
                            } else {
                                colspan = Math.ceil(dayjs(endDate).diff(startDate, difftype, true)); console.info(colspan);
                                console.info(dayjs(endDate).format('YYYY-MM-DD HH') + "-------" + dayjs(startDate).format('YYYY-MM-DD HH'));
                            }
                        }


                        var diff_day = dayjs(startDate).diff(plans, difftype)
                        if (dayjs(endDate) > dayjs(startDate)) {
                            rowid.css('position', 'relative');
                            rowid.append("<div class='ganttDiv' style='width:" + width * colspan + "px;left:" + diff_day * width + "px;background:" + data.rows[j].color + "'>" + data.rows[j].CONTAINER + "</div>");
                        }

                    }
                }
            });

            $('#Apscolumns').combogrid({
                data: Apscolumns,
                panelWidth: 160,
                idField: 'field',
                textField: 'title',
                columns: [[{ field: 'field', title: 'ID', width: 80, checkbox: true },
				{ field: 'title', title: '列名', width: 120 }, ]],
                onSelect: function (index, row) {
                    $('#ApsTest').datagrid('showColumn', row.field);
                    var values = $('#Apscolumns').combobox('getValues');
                    Apscolumns.forEach(function (item) {
                        var isExist = values.some(function (i) {
                            return i === item.field
                        });
                        if (!isExist && item.field != row.field) { $('#ApsTest').datagrid('hideColumn', item.field); }
                    });
                },
                onUnselect: function (index, row) {
                    var values = $('#Apscolumns').combobox('getValues');
                    $.each(Apscolumns, function (index, item) {
                        if (item.field == row.field) { $('#ApsTest').datagrid('showColumn', row.field); } else { $('#ApsTest').datagrid('hideColumn', row.field); }
                    });
                },
                onChange: function (newValue, oldValue) {
                    if (newValue.length == 0 || newValue.length == Apscolumns.length) {
                        $.each(Apscolumns, function (index, item) {
                            $('#ApsTest').datagrid('showColumn', item.field);
                        });
                    }
                }
            });

            $('#ApsSpec').datagrid({
                singleSelect: true,
                frozenColumns: [[{ field: 'XX', title: '操作', width: 80}]],
                columns: [specColumns],
                onSelect: function (index, row) {
                },
                onClickCell: function (index, field, value) {
                }
            });
        },
        initData: function () {
            var data = [{ id: 100, CONTAINER: 'xxx-2023-01', WORKFLOWNERSION: 'XXX-MM:01', WORKFLOWSTEP: '005-工序', ISCOMP: '是', WORKCENTER: 'XX工区', PLANSTART: '2023-08-07 00:00:00', PLANEND: '2023-09-30 01:00:00', DAYS: 7, DAYE: 20, name: 'xxxxx-2222', periods: [{ end: "2023/3/10 8:41:00", fill: "#5FB878", id: "xxx", start: "2023/3/7 8:30:00", text: "ZS2023-1802004"}] },
                { id: 200, CONTAINER: 'xxx-2023-02', WORKFLOWNERSION: 'XXX-MM:02', WORKFLOWSTEP: '010-工序', ISCOMP: '否', WORKCENTER: 'YYY工区', PLANSTART: '2023-08-01 22:00:00', PLANEND: '2023-08-08 23:01:00', DAYS: 2, DAYE: 25 }
            ]
            var colors = ['#67C23A', '#E6A23C', '#67C23A', '#409EFF', '#FFF940']
            for (var i = 0; i <= 20; i++) {
                var id = 100;
                if (i > 10) { id = 200; }
                var color = 'red'
                if (i % 2 == 0) { color = colors[0]; }
                if (i % 3 == 0) { color = colors[1]; }
                if (i % 5 == 0) { color = colors[2]; }
                data.push({ id: i, _parentId: id, color: color, CONTAINER: 'xxx-2023-01' + i, WORKFLOWNERSION: 'XXX-MM:01', WORKFLOWSTEP: '005-工序', ISCOMP: '是', WORKCENTER: 'XX工区', PLANSTART: dayjs('2023-08-17').add(i, 'hour').format('YYYY-MM-DD HH:mm:ss'), PLANEND: dayjs('2023-08-31').subtract(i, 'hour').format('YYYY-MM-DD HH:mm:ss'), DAYS: 7, DAYE: 20, name: 'ZS2023-1802004' + i, periods: [{ end: "2023/3/10 8:41:00", fill: "#5FB878", id: i, start: "2023/3/13 8:30:00"}] });
            }

            $('#ApsTest').datagrid('loadData', data);
            $('#ApsTest1').datagrid('loadData', data);
            var data11 = { total: data.length, rows: data }
            $('#Table1').datagrid('loadData', data);
            $('#tt').treegrid('loadData', data11);
            var data1 = [{ SPECNO: '005', SPECNAME: '工序1', SPECTYPE: '一般序', EQU: 'XX-01', PLANSTART: '2023-08-07', PLANEND: '2023-08-31', PLANTIME: '20', PREPARECYCLE: '23', MAKECYCLE: '56', TRANSFERCYCLE: '50', COMMICYCLE: '2', DAYS: 1, DAYE: 5 },
                { SPECNO: '010', SPECNAME: '工序', SPECTYPE: '一般序', EQU: 'XX-01', PLANSTART: '2023-08-07', PLANEND: '2023-08-31', PLANTIME: '20', PREPARECYCLE: '23', MAKECYCLE: '56', TRANSFERCYCLE: '50', COMMICYCLE: '2', DAYS: 6, DAYE: 10 },
                { SPECNO: '015', SPECNAME: '工序2', SPECTYPE: '检验序', EQU: 'XX-01', PLANSTART: '2023-08-07', PLANEND: '2023-08-31', PLANTIME: '20', PREPARECYCLE: '23', MAKECYCLE: '56', TRANSFERCYCLE: '50', COMMICYCLE: '2', DAYS: 11, DAYE: 17 },
                { SPECNO: '020', SPECNAME: '工序3', SPECTYPE: '一般序', EQU: 'XX-01', PLANSTART: '2023-08-07', PLANEND: '2023-08-31', PLANTIME: '20', PREPARECYCLE: '23', MAKECYCLE: '56', TRANSFERCYCLE: '50', COMMICYCLE: '2', DAYS: 18, DAYE: 23 },
                { SPECNO: '025', SPECNAME: '工序4', SPECTYPE: '一般序', EQU: 'XX-01', PLANSTART: '2023-08-07', PLANEND: '2023-08-31', PLANTIME: '20', PREPARECYCLE: '23', MAKECYCLE: '56', TRANSFERCYCLE: '50', COMMICYCLE: '2', DAYS: 24, DAYE: 26 },
                { SPECNO: '030', SPECNAME: '工序5', SPECTYPE: '一般序', EQU: 'XX-01', PLANSTART: '2023-08-07', PLANEND: '2023-08-31', PLANTIME: '20', PREPARECYCLE: '23', MAKECYCLE: '56', TRANSFERCYCLE: '50', COMMICYCLE: '2', DAYS: 27, DAYE: 30 },
            ]
            $('#ApsSpec').datagrid('loadData', data1);
            $('#ApsSpec').datagrid('getPanel').hide();
        },
        SelectContainer: function (obj) {
            $('#ApsSpec').datagrid('getPanel').show("slow");
            $('#ApsTestlayout').hide("slow");
        },
        returnContainer: function () {
            $('#ApsTestlayout').show("slow");
            $('#ApsSpec').datagrid('getPanel').hide("slow");
        },
        getDays: function (start, end) {
            var startDated = Date.parse(start);
            var endDated = Date.parse(end);
            var date = Math.abs(endDated - startDated);
            var allDay = Math.floor(date / (1000 * 3600 * 24));
            return allDay;
        },
        //查询
        searchData: function () {
            page.bind();
            page.initData();
            clearMessage();
        },
        //查询重置
        searchReset: function () {
            $('#searchForm').form('clear');
            page.bind();
            clearMessage();
        },
        //清除方法，重要！！！
        reset: function (iscondition, isresult) {
            clearMessage();
        },

        //post数据
        post: function (param, async, callback) {
            $.ajax({
                type: "Post",
                url: page.ajaxUrl,
                data: param,
                cashe: false,
                async: async,
                dataType: "json",
                beforeSend: function () {
                    $.messager.progress({ text: '', msg: '处理中...' });
                },
                success: function (data) {
                    $.messager.progress('close');
                    callback(data);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.progress('close');
                    displayMessage(XMLHttpRequest.responseText, false);
                }
            });
        }
    }

    $(function () {
        page.init();
        // easyui datagrid 左边区域滚动事件监听
        $('#center .datagrid-body:eq(0)').scroll(function () {
            $('#east .datagrid-body:eq(1)').scrollTop(this.scrollTop)
        })
        // easyui datagrid 右边区域滚动事件监听
        $('#east .datagrid-view2 .datagrid-body').scroll(function () {
            $('#center .datagrid-body').scrollTop(this.scrollTop)
        })
        $('#east .datagrid-row').on('mouseover', function () {
            //console.info($(this).attr('datagrid-row-index'));
            var index = $(this).attr('datagrid-row-index'); 
            var row = $('#ApsTest1').datagrid('getRows')[index];
            $(this).tooltip({ position: 'top',
                content: function () {
                    var div = '<div style="padding:1px;background:#eee;color:#000"><p>批次号：' + row.CONTAINER + '</p><p>计划开始：' + row.PLANSTART + '</p><p>计划结束：' + row.PLANEND + '</p></div>';
                    return div;
                },
                onShow: function () {
                    $(this).tooltip('tip').css({
                        backgroundColor: '#666',
                        borderColor: '#666'
                    });
                },
                onPosition: function () {
                    //$(this).tooltip('tip').css('left', $(this).offset().left);
                    $(this).tooltip('arrow').css('left', 100);
                }
            });
        });
    });
</script>
